<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>2</title>
</head>

<body>

    <script>
        var str = "2022-4-6 11:11"
        var reg1 = /-\d\D/g
        var reg2 = /-\d(?!\d)/g

        // 正则匹配从左到右且不掉头、不重复。reg1只能匹配-4-，而reg2可以匹配-4和-6

        console.log(str.match(reg))
    </script>

</body>

</html>